<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>获取URL参数</h1>
<hr>

<script>
    //获取URL参数的函数
    function getQueryVariable(variable) {
        let query = window.location.search.substring(1);
        let vars = query.split("&");
        for (let i = 0; i < vars.length; i++) {
            let pair = vars[i].split("=");
            if (pair[0] == variable) {
                return decodeURI(pair[1]); //对中文参数进行编码
            }
        }
        return (false);
    }

    console.log(getQueryVariable('id'));
</script>
</body>
</html>